#ifndef SHOWFACTORY_H
#define SHOWFACTORY_H

#include <QObject>

class QTextStream;
class QDir;
class QAbstractListModel;

class ShowLoader;
class ShowFileParser;
class IF_ShowWriterInterface;
class ShowFileFormatter;
class ApplicationSettings;

class MediaListModel;
class LightPresetModel;
class SequenceModel;
class IF_ScriptEngineInterface;
class IF_ShowGuiInterface;

/**
 * @brief factory interface
 */
class IF_ShowFactoryInterface : public QObject
{
   Q_OBJECT
public:
   explicit IF_ShowFactoryInterface(QObject *parent = 0) : QObject(parent) {}
   virtual ~IF_ShowFactoryInterface() {}

   virtual IF_ShowGuiInterface *buildShowGui() = 0;

   virtual ShowLoader * buildShowLoader( IF_ShowGuiInterface *selectDialog,
                                         MediaListModel *mediaModel,
                                         LightPresetModel *lightModel,
                                         SequenceModel *sequenceModel,
                                         IF_ScriptEngineInterface *scriptInterafce,
                                         ApplicationSettings & appSettings) = 0;

   virtual IF_ShowWriterInterface *buildShowWriter(ShowFileFormatter *formatter) = 0;

   virtual ShowFileFormatter *buildShowFileFormatter(const IF_ScriptEngineInterface &script,
                                                     const QAbstractListModel &mediaModel,
                                                     const QAbstractListModel &lightsetModel,
                                                     const QAbstractListModel &sequenceModel) = 0;

   virtual void deleteShowGui( IF_ShowGuiInterface *showGui) = 0;
   virtual void deleteShowLoader( ShowLoader * showLoader) = 0;
   virtual void deleteShowWriter( IF_ShowWriterInterface *showWriter) = 0;
   virtual void deleteShowFileFormatter( ShowFileFormatter *formatter) = 0;
};

/**
 * @brief Concrete factory that builds objects when the user
 *    issues commands to save or load a show.
 * Note that target files have not been selected yet.
 */
class ShowFactory : public IF_ShowFactoryInterface
{
   Q_OBJECT
public:
   explicit ShowFactory(int numOfLightChannels, ApplicationSettings & appSettings, QObject *parent = 0);

   virtual IF_ShowGuiInterface *buildShowGui();

   virtual ShowLoader * buildShowLoader( IF_ShowGuiInterface *selectDialog,
                                         MediaListModel *mediaModel,
                                         LightPresetModel *lightModel, SequenceModel *sequenceModel,
                                         IF_ScriptEngineInterface *scriptInterafce,
                                         ApplicationSettings & appSettings);

   virtual IF_ShowWriterInterface *buildShowWriter(ShowFileFormatter *formatter);

   virtual ShowFileFormatter *buildShowFileFormatter(const IF_ScriptEngineInterface &script,
                                                     const QAbstractListModel &mediaModel,
                                                     const QAbstractListModel &lightsetModel,
                                                     const QAbstractListModel &sequenceModel);

   virtual void deleteShowGui(IF_ShowGuiInterface *showGui);
   virtual void deleteShowLoader(ShowLoader *showLoader);
   virtual void deleteShowWriter(IF_ShowWriterInterface *showWriter);
   virtual void deleteShowFileFormatter(ShowFileFormatter *formatter);

private:
   int m_numOfLightChannels;
   ApplicationSettings & m_appSettings;
};

#endif // SHOWFACTORY_H
